import requests

from py02_tpshop_api import TPshop_Login_Api


class Test_Tpshop_Login:
    session=None
    def setup(self):
        self.session = requests.Session()
        TPshop_Login_Api.get_verify(self.session)

    def test01_login_sucess(self):

        login_data = {"username": "13800000002", "password": "123456", "verify_code": "8888"}
        res = TPshop_Login_Api.login(self.session, login_data)

        assert 200 == res.status_code
        assert 1 == res.json().get("status")
        assert "登陆成功" in res.json().get("msg")

    def test02_pwd_err(self):

        login_data = {"username": "13800000002", "password": "1234516", "verify_code": "8888"}
        res = TPshop_Login_Api.login(self.session, login_data)
        print(res.json())
        assert 200 == res.status_code
        assert -2 == res.json().get("status")
        assert "密码错误" in res.json().get("msg")

    def test03_verify_err(self):

        login_data = {"username": "13800000002", "password": "123456", "verify_code": "81888"}
        res = TPshop_Login_Api.login(self.session, login_data)
        print(res.json())
        assert 200 == res.status_code
        assert 0 == res.json().get("status")
        assert "验证码错误" in res.json().get("msg")
